//
//  AppConfig.h
//  Delicious
//
//  Created by apple on 11-11-4.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <string.h>
#import <netinet/in.h>
#import <sys/socket.h>
#import <SystemConfiguration/SCNetworkReachability.h>
//#import "CRootCtrlManager.h"
#import "CQWeiBo.h"
#import "CSinaWeibo.h"
#import "CRenren.h"
#import "ReachabilityEx.h"
#import "Message.h"
#import "CTextField.h"

#define DEFAULT_ICON        @"dicon.png"
#define DEFAULT_IMAGE       @"image.png"
#define DEFAULT_TOUXIANG    @"personal.png"

#define kPreferencesPlistPath @"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"

//@class CRootCtrlManager;
@class CDBManager;

//===========================================================================================================

@interface CCommand : NSObject

@property (nonatomic, assign) int   m_nCmd;
@property (nonatomic, assign) int   m_mSubCmd;
@property (nonatomic, retain) id    m_CmdInfo;

+(CCommand*)GetCommandWithInfo:(int)cmd SubCmd:(int)subcmd CmdInfo:(id)cmdinfo;

@end

//===========================================================================================================

@interface CExAppInfo : NSObject

@property (nonatomic, retain) NSString  *m_strType;             //1sina,2tengxun
@property (nonatomic, retain) NSString  *m_strTokenKey;
@property (nonatomic, retain) NSString  *m_strSecret;


-(id)InitWithValue:(NSString*)tokenkey Secret:(NSString*)secret Type:(NSString*)type;

@end

/************************************************************************
 *概述:整个程序的配置
 *作者:张轶龙 2011/11/04
 ************************************************************************
 *更改日志:2011/11/03 张轶龙添加了类说明
 *
 ************************************************************************/

typedef enum {zhHans, en}Language;

@interface AppConfig : NSObject

@property  (nonatomic, assign) UIViewController     *m_DeliciousCtrl;       //程序root控制器
@property  (nonatomic, assign) NSString             *m_DelImagesPath;
@property  (nonatomic, assign) NSString             *m_FriendsimagesPath;
@property  (nonatomic, assign) NSString             *m_DraftPath;
@property  (nonatomic, assign) NSString             *m_IConsPath;
@property  (nonatomic, assign) NSMutableDictionary  *m_ExAppDic;

@property  (nonatomic, assign) Language             m_Language;

//@property  (nonatomic, assign) ReachabilityEx* hostReach;
//@property  (nonatomic, assign) ReachabilityEx* internetReach;
//@property  (nonatomic, assign) ReachabilityEx* wifiReach;

@property  (nonatomic, retain) NSString             *m_strUDID;

//network
@property BOOL m_bIsCheckNet;
@property BOOL m_bIsNetWork;
@property (nonatomic, assign) NSTimer   *m_NetTimer;


/************************************************************************
 *函数功能:获取全局的配置实例
 *作者:    张轶龙 2011/11/04
 *返回值:   无
 ************************************************************************
 *更改日志：2011/11/03 张轶龙添加了函数头 
 *
 ************************************************************************/

+(AppConfig*)DefaultAppConfig;

/************************************************************************
 *函数功能:释放全局的配置实例
 *作者:    张轶龙 2011/11/04
 *返回值:   无
 ************************************************************************
 *更改日志：2011/11/03 张轶龙添加了函数头 
 *
 ************************************************************************/

+(void)DestroyAppConfig;

-(BOOL)CheckNetwork;

-(void)CreateAppDirectory;

-(BOOL)IsContainChinese:(NSString*)source;

-(void)SaveImage:(UIImage*)image Path:(NSString*)path Compress:(float)compress;
-(NSString*)SvaeImageToDir:(UIImage*)image Path:(NSString*)path FileName:(NSString*)filename;


-(NSString*)CreatePathInApp:(NSString*)mainpath SubPath:(NSString*)subpath;
-(void)RemovePathInApp:(NSString*)mainpath SubPath:(NSString*)subpath;
-(NSString*)PathIsInApp:(NSString*)mainpath SubPath:(NSString*)subpath;
-(NSString*)GetFilePathInApp:(NSString*)mainpath SubPath:(NSString*)subpath FileName:(NSString*)fielname;
-(NSString*)FileIsInExitPath:(NSString*)mainpath SubPath:(NSString*)subpath FileName:(NSString*)fielname;
-(NSString*)WriteFileToExistPath:(NSString*)mainpath SubPath:(NSString*)subpath Data:(NSData*)data FileName:(NSString*)fielname;
-(NSData*)GetFileFromExistPath:(NSString*)mainpath SubPath:(NSString*)subpath FileName:(NSString*)fielname;
-(NSString*)RemoveFileInApp:(NSString*)mainpath SubPath:(NSString*)subpath FileName:(NSString*)fielname;
-(void)RemoveFile:(NSString*)path;

//时间相关
-(NSString*)GetTimeFormatString;
-(long long)DateToInt:(NSString*)date;
-(NSDate*)IntToDate:(long long)time;

-(void)GetOSCurLanguage;
@end


@interface UITextField (Check)

-(void)IsNameRightFormat:(int)length;
-(void)IsPwdRightFormat:(int)length;
-(void)IsNickRightFormat:(int)length;
-(void)IsChineseRightFormat;

@end

